home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / basdir.arc / CATALOG.BAS (.txt) next >
Encoding:
GW-BASIC  |  1985-11-01  |  3.3 KB  |  75 lines

  1. 1  'This program will create a CATALOG of all the files on drive C.
  2. 2  'It will search through all the directory and produce a listing
  3. 3  'on the printer in both alphabetical order and in decending size.
  4. 4  'Files that are special (hidden, read only, system) are flagged with
  5. 5  'an "*". The first 8 characters of the path (directory) name are
  6. 6  'also printed out. This is another example of the FCBREAD.BSV program.
  7. 7  'Jim Holtman
  8. 8  '35 Dogwood Trail
  9. 9  'Randolph, NJ 07869
  10. 10  ' (201) 361-3395
  11. 100  CLEAR ,&HF000  'make room for FCBREAD.BSV
  12. 110  BLOAD.BASE=&HF000<UNK! {0009}>'base @ of subroutine
  13. 120    COL=4:ROWS=83
  14. 130  NFILES=0
  15. 140    TWIDTH=132/COL
  16. 150    WIDTH "lpt1:",255
  17. 160    DIM SINPUT$(COL*ROWS+COL)
  18. 170  LPRINT CHR$(27) "@";<UNK! {0009}><UNK! {0009}>'init the EPSON printer
  19. 180  Q$="'"
  20. 190  INPUT "Output sorted by size? - (y/n) ",RESP$
  21. 200  BLOAD "fcbread.bsv",BLOAD.BASE
  22. 210  OPEN "\catalog.ust" FOR OUTPUT AS #1
  23. 220  IMAX%=100:INEXT%=1
  24. 230  O%=PEEK(BLOAD.BASE)+PEEK(BLOAD.BASE+1)*256+29+BLOAD.BASE
  25. 240  DIM DIR$(IMAX%)
  26. 250  CLS:PRINT "ROOT"
  27. 260  CHDIR "\"            'start at the ROOT
  28. 270  CUR$=""<UNK! {0009}>'current directory
  29. 280  INIT%=BLOAD.BASE+2:GETNEXT%=BLOAD.BASE+5<UNK! {0009}>'entry points for routines
  30. 290  VOLPAT$="???????????"<UNK! {0009}>'match ANY file name (check for VOLUME first)
  31. 300  DISK%=3:CALL INIT%(DISK%,VOLPAT$)<UNK! {0009}>'set to use C drive
  32. 310  VOLNAME$=SPACE$(14):CALL GETNEXT%(VOLNAME$,STATUS%)
  33. 320  IF STATUS%<0 THEN GOTO 340
  34. 330  IF STATUS%=8 THEN I%=INSTR(VOLNAME$,"."):VOLNAME$=MID$(VOLNAME$,3,I%-3)+MID$(VOLNAME$,I%+1):GOTO 350 ELSE GOTO 310
  35. 340  VOLNAME$=MID$(VOLNAME$,3,INSTR(VOLNAME$,".")-3)
  36. 350  PAT$="???????????"<UNK! {0009}>'match any file name
  37. 360  DISK%=3:CALL INIT%(DISK%,PAT$)
  38. 370  FILENAME$=SPACE$(14):CALL GETNEXT%(FILENAME$,STATUS%)
  39. 380  REM if no file found, go down last directory
  40. 390  IF STATUS%<0 THEN IF INEXT%>1 THEN INEXT%=INEXT%-1:CUR$=DIR$(INEXT%):CHDIR CUR$:PRINT CUR$:GOTO 360 ELSE GOTO 550
  41. 400  DISK$=LEFT$(FILENAME$,2):FILENAME$=MID$(FILENAME$,3)
  42. 410  IF (STATUS% AND &H10)=0 THEN GOTO 480<UNK! {0009}>'check for directory entry
  43. 420  IF LEFT$(FILENAME$,1)="." THEN GOTO 370      'ignore "." entries
  44. 430  FILENAME$=LEFT$(FILENAME$,INSTR(FILENAME$,".")-1)
  45. 440  IF INEXT%>IMAX% THEN PRINT "Directory Stack Overflow":GOTO 370
  46. 450  DIR$(INEXT%)=CUR$+"\"+FILENAME$
  47. 460  INEXT%=INEXT%+1
  48. 470  GOTO 370
  49. 480  REM IF (STATUS% AND &HF) <> 0 THEN GOTO 260      'ignore if not NORMAL file
  50. 490  FSIZE#=((PEEK(O%+3)*256+PEEK(O%+2))*256+PEEK(O%+1))*256+PEEK(O%)<UNK! {0009}>'get size
  51. 500  PRINT#1,USING "\          \ \      \#######";FILENAME$;CUR$;FSIZE#;
  52. 510  IF (STATUS% AND &HF) <> 0 THEN PRINT#1,"*" ELSE PRINT#1,<UNK! {0009}>'check for special file type
  53. 520  NFILES=NFILES+1
  54. 530  GOTO 370
  55. 540  REM Use the SORT command to sort the file (invoked with SHELL)
  56. 550  CLOSE:PRINT "SORTING FILE NAMES":START=TIMER:SHELL("sort <\catalog.ust >\catalog.srt"):PRINT TIMER-START " seconds":GOSUB 600
  57. 560  CLOSE:IF RESP$<>"y" THEN SYSTEM
  58. 570  PRINT "Sorting by size";:START=TIMER:SHELL("sort /r/+23 <\catalog.ust >\catalog.srt"): PRINT TIMER-START " seconds":GOSUB 600
  59. 580  SYSTEM
  60. 590  REM Print out the sorted file
  61. 600  OPEN "\catalog.srt" FOR INPUT AS #1
  62. 610  I=0:PAGENO=0
  63. 620  WHILE (NOT EOF(1)) AND (I<COL*ROWS)
  64. 630  I=I+1
  65. 640  LINE INPUT#1,SINPUT$(I)
  66. 650  WEND
  67. 660  FOR J=I+1 TO I+COL:SINPUT$(J)="":NEXT   'make sure blank entries at end of table
  68. 670  J=(I-1)\COL+1
  69. 680  PAGENO=PAGENO+1:LPRINT CHR$(18)CHR$(27)"-1System Catalog:" NFILES "Files  " DATE$ "     " TIME$ "    Page -" PAGENO CHR$(27) "-0":LPRINT CHR$(15) CHR$(27) "0"
  70. 690  FOR K=1 TO J
  71. 700  FOR C=0 TO COL-1:LPRINT TAB(C*TWIDTH+1);MID$(SINPUT$(K+C*J),1,TWIDTH);:NEXT
  72. 710  NEXT
  73. 720  IF NOT EOF(1) THEN I=0:LPRINT CHR$(12);:GOTO 620
  74. 730  LPRINT CHR$(12):RETURN
  75.